#!/bin/sh
#
# Create a table counting all known email - country associations known
#
mysql -h ${COUNTER_DBHOST-localhost} counter <<EoF
drop table temp_domcountry;
EoF

mysql -h ${COUNTER_DBHOST-localhost} counter <<EoF
create table temp_domcountry (
    count int,
    domain varchar(128),
    country char(2));

insert into temp_domcountry
   select count(*), substring_index(email, '@', -1) as domain, country
   from persons
   where f_clean not like '%clean-email%'
   group by domain, country; 
EoF
